﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Contact.ascx.cs" Inherits="ERP.Modules.Contact" %>

<%-------------------------------%>
<ext:Hidden ID="FormatTypeContact" runat="server" />
<ext:Panel runat="server" Layout="Fit" Border="False" ID="PanelContact">
    <Content>
        <%--------------GridContact-----------------%>
        <ext:GridPanel
            ID="grContact"
            Cls="grid-double"
            runat="server"
            EnableColumnMove="true"
            Border="False">
            <%-------------StoreContact-----------------%>
            <Store>
                <ext:Store
                    ID="StoreContact"
                    runat="server"
                    OnReadData="StoreContact_RefreshData"
                    PageSize="20">
                    <Model>
                        <ext:Model ID="ModelContact" runat="server" IDProperty="Contact_ID">
                            <Fields>
                                <ext:ModelField Name="Contact_Alias" Type="String" />
                                <ext:ModelField Name="Contact_Name" Type="String" />
                                <ext:ModelField Name="Contact_BirthDay" Type="Date" />
                                <ext:ModelField Name="Contact_Gender" Type="String" />
                                <ext:ModelField Name="Contact_Phone" Type="String" />
                                <ext:ModelField Name="Contact_MobilePhone" Type="String" />
                                <ext:ModelField Name="Contact_Email" Type="String" />
                                <ext:ModelField Name="Contact_Address" Type="String" />
                                <ext:ModelField Name="Contact_Note" Type="String" />
                            </Fields>
                        </ext:Model>
                    </Model>
                </ext:Store>
            </Store>
            <ColumnModel runat="server">
                <Columns>
                    <ext:RowNumbererColumn ID="RowNumbererColumn1" runat="server" Width="30" Align="Center" />
                    <ext:Column ID="Column2" runat="server" Text="Mã người liên hệ" Width="100" DataIndex="Contact_Alias"></ext:Column>
                    <ext:Column ID="Column3" runat="server" Text="Tên người liên hệ" Width="150" DataIndex="Contact_Name"></ext:Column>
                    <ext:DateColumn runat="server" Text="Ngày sinh" Width="100" DataIndex="Contact_BirthDay" Format="dd-MM-yyyy" Align="Center"></ext:DateColumn>
                    <ext:Column ID="Column5" runat="server" Text="Giới tính" Width="50" DataIndex="Contact_Gender"></ext:Column>
                    <ext:Column ID="Column7" runat="server" Text="Điện thoại" Width="90" DataIndex="Contact_Phone"></ext:Column>
                    <ext:Column ID="Column8" runat="server" Text="Di động" Width="90" DataIndex="Contact_MobilePhone"></ext:Column>
                    <ext:Column ID="Column9" runat="server" Text="Email" Width="100" DataIndex="Contact_Email"></ext:Column>
                    <ext:Column ID="Column10" runat="server" Text="Địa chỉ" Width="100" DataIndex="Contact_Address"></ext:Column>
                    <ext:Column ID="Column4" runat="server" Text="Ghi chú" Width="100" DataIndex="Contact_Note" Flex="1"></ext:Column>
                </Columns>
            </ColumnModel>
            <DirectEvents>
                <ItemDblClick OnEvent="ContactDblClick">
                    <ExtraParams>
                        <ext:Parameter Name="Contact_ID" Value="record.data.Contact_ID" Mode="Raw" />
                    </ExtraParams>
                    <EventMask ShowMask="true" Msg="Đang tải..." />
                </ItemDblClick>
            </DirectEvents>
            <SelectionModel>
                <ext:CheckboxSelectionModel ID="CheckboxSelectionModelContact" runat="server" Mode="Multi">
                    <Listeners>
                       <SelectionChange Handler="
                            if (selected.length == 0) {
                                #{btnEdit}.disable();
                                #{btnDel}.disable();
                                #{btnExport}.disable();
                            } else {
                                #{btnEdit}.enable();
                                #{btnDel}.enable();
                                #{btnExport}.enable();
                            }" />
                   </Listeners>
                </ext:CheckboxSelectionModel>
            </SelectionModel>
            <DockedItems>
                <ext:Toolbar ID="ToolbarTopMain" runat="server" Dock="Top">
                    <Items>
                        <ext:Button ID="btnAddNew" runat="server" Text="Thêm mới" Icon="ApplicationAdd">
                            <DirectEvents>
                                <Click OnEvent="btnAddNew_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Click>
                            </DirectEvents>
                        </ext:Button>

                        <ext:Button ID="btnEdit" runat="server" Text="Sửa" Icon="ApplicationEdit">
                            <DirectEvents>
                                <Click OnEvent="btnEdit_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Click>
                            </DirectEvents>
                        </ext:Button>

                        <ext:Button ID="btnDel" runat="server" Text="Xoá" Icon="ApplicationDelete">
                            <DirectEvents>
                                <Click OnEvent="btnDel_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                    <ExtraParams>
                                        <ext:Parameter Name="name" Value="btnDel"></ext:Parameter>
                                    </ExtraParams>
                                    <Confirmation ConfirmRequest="true"
                                        Title="Thông Báo" Message="Bạn có muốn xoá mẫu tin này không ?">
                                    </Confirmation>
                                </Click>
                            </DirectEvents>
                        </ext:Button>

                        <ext:Button ID="btnExport" runat="server" Text="Xuất tập tin" Icon="Printer">
                            <Menu>
                                <ext:Menu ID="MenuMain" runat="server">
                                    <Items>
                                        <ext:MenuItem ID="MenuItemExportXML" runat="server" Text="XML" Icon="PageCode">
                                            <Listeners>
                                                <Click Handler="submitValue(#{grContact}, #{FormatTypeContact}, 'xml');" />
                                            </Listeners>
                                        </ext:MenuItem>
                                    </Items>
                                </ext:Menu>
                            </Menu>
                        </ext:Button>

                    </Items>
                </ext:Toolbar>
                <ext:Toolbar ID="ToolbarPagging" runat="server" Dock="Bottom" AnchorHorizontal="100%">
                    <Items>
                        <ext:TriggerField ID="txtSearch" runat="server" Width="200" EnableKeyEvents="true" MarginSpec="0 8 0 0">
                            <Triggers>
                                <ext:FieldTrigger Icon="Search" />
                            </Triggers>
                            <DirectEvents>
                                <TriggerClick OnEvent="Search_Event"></TriggerClick>
                                <KeyPress OnEvent="Search_Event"></KeyPress>
                            </DirectEvents>
                        </ext:TriggerField>
                        <ext:PagingToolbar ID="PagingToolbarContact" runat="server" StoreID="StoreContact" BeforePageText="Trang" AfterPageText="của {0}" LastText="Cuối" NextText="Kế tiếp" PrevText="Trở lại" FirstText="Đầu" RefreshText="Làm tươi" DisplayInfo="true" DisplayMsg="Trang {0} - {1} của {2}" />
                    </Items>
                </ext:Toolbar>
            </DockedItems>
        </ext:GridPanel>
    </Content>
</ext:Panel>
<ext:Panel runat="server">
    <Content>
        <%-----------WindowsContact-----------------%>
        <ext:Window ID="WindowsContact" runat="server"
            Title="Cập nhật người liên hệ"
            DefaultAnchor="100%"
            Width="832px"
            Height="288px"
            Hidden="true"
            AutoScroll="false"
            Maximizable="False"
            Minimizable="False"
            AutoDataBind="true"
            Region="Center"
            Resizable="false"
            Modal="true"
            HideMode="Offsets"
            Border="false"
            Padding="5"
            DefaultButton="btnSavePopUp">
            <Items>
                <ext:Toolbar ID="ToolbarContact" runat="server">
                    <Items>
                        <ext:Button runat="server" Text="Lưu lại" Icon="Disk" ID="btnSavePopUp">
                            <DirectEvents>
                                <Click OnEvent="btnSavePopUp_Click" Before="return #{FormPanelContact}.isValid();">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                        <ext:Button runat="server" Text="Huỷ bỏ" Icon="Decline" ID="btnCancelPopUp">
                            <DirectEvents>
                                <Click OnEvent="btnCancelPopUp_Click">
                                    <EventMask ShowMask="true" Msg="Đang tải..." />
                                </Click>
                            </DirectEvents>
                        </ext:Button>
                        <ext:TextField ID="txtContact_ID" runat="server" FieldLabel="ID" LabelAlign="Right" Hidden="true" />
                    </Items>
                </ext:Toolbar>
                <%--<ext:TreePanel
            ID="TreePanel1"
            runat="server"
            Height="300"
            Width="200"
            AutoScroll="true"
            Animate="true"
            RootVisible="false"
            ContainerScroll="true">

            <Fields>
                <ext:ModelField Name="Contact_ID" Type="Int" />
                <ext:ModelField Name="Contact_Name" Type="String" />
            </Fields>

            <ColumnModel>
                <Columns>
                    <ext:TreeColumn ID="TreeColumn1" runat="server" DataIndex="text" Text="Contact_Name" Flex="1">
                    </ext:TreeColumn>
                </Columns>
            </ColumnModel>
        </ext:TreePanel>--%>
                <ext:FormPanel ID="FormPanelContact" runat="server"
                    BodyPadding="10"
                    Frame="true"
                    DefaultAnchor="100%">
                    <Items>
                        <ext:FieldContainer
                            runat="server"
                            AnchorHorizontal="100%"
                            Layout="HBoxLayout">
                            <Items>
                                <ext:TextField ID="txtContact_Alias" runat="server" FieldLabel="Mã người liên hệ" AllowBlank="false" Width="250" Margins="0 20 0 0" />
                                <ext:TextField ID="txtContact_Name" runat="server" FieldLabel="Họ tên" AllowBlank="false" Width="520px" />
                            </Items>
                        </ext:FieldContainer>
                        <ext:FieldContainer
                            runat="server"
                            AnchorHorizontal="100%"
                            Layout="HBoxLayout">
                            <Items>
                                <ext:DateField ID="txtContact_Birthday" runat="server" FieldLabel="Ngày sinh" Width="250" AllowBlank="false" Margins="0 20 0 0" />
                                <ext:DisplayField runat="server" Width="105"></ext:DisplayField>
                                <ext:RadioGroup ID="RadioGroupContact_Gender" runat="server" FieldLabel="Giới tính" ColumnsNumber="2" AutomaticGrouping="false">
                                    <Items>
                                        <ext:Radio ID="chkContact_Gender" runat="server" Name="rating" InputValue="Nữ" BoxLabel="Nữ" />
                                        <ext:Radio ID="chkContact_Gender_Male" runat="server" Name="rating" InputValue="Nam" BoxLabel="Nam" Checked="True" />
                                    </Items>
                                </ext:RadioGroup>
                            </Items>
                        </ext:FieldContainer>
                        <ext:FieldContainer
                            runat="server"
                            AnchorHorizontal="100%"
                            Layout="HBoxLayout">
                            <Items>
                                <ext:ComboBox ID="cbJob"
                                    runat="server"
                                    QueryMode="Local"
                                    SelectOnFocus="true"
                                    ForceSelection="True"
                                    FieldLabel="Chức vụ"
                                    Width="223"
                                    AllowBlank="false"
                                    Margins="0 5 0 0"
                                    DisplayField="Job_Name"
                                    ValueField="Job_ID"
                                    EmptyText="Vui lòng chọn chức vụ"
                                    ContextMenuID="cbJobContext">
                                    <Store>
                                        <ext:Store runat="server" ID="JobStore" OnReadData="ReloadComboBox">
                                            <Model>
                                                <ext:Model ID="JobModel" runat="server" IDProperty="Job_ID">
                                                    <Fields>
                                                        <ext:ModelField Name="Job_Name" Type="String" />
                                                    </Fields>
                                                </ext:Model>
                                            </Model>
                                        </ext:Store>
                                    </Store>
                                </ext:ComboBox>
                                <ext:Button runat="server" Icon="Add" Margins="0 20 0 0">
                                    <Listeners>
                                        <Click Handler="#{WindowsJob}.show();"></Click>
                                    </Listeners>
                                    <ToolTips>
                                        <ext:ToolTip runat="server" Html="Thêm mới chức vụ" />
                                    </ToolTips>
                                </ext:Button>
                                <ext:ComboBox ID="cbVocative"
                                    runat="server"
                                    QueryMode="Local"
                                    SelectOnFocus="true"
                                    ForceSelection="True"
                                    FieldLabel="Danh xưng"
                                    Width="223"
                                    AllowBlank="false"
                                    Margins="0 5 0 0"
                                    DisplayField="Vocative_Name"
                                    ValueField="Vocative_ID"
                                    EmptyText="Vui lòng chọn danh xưng"
                                    ContextMenuID="cbVocativeContext">
                                    <Store>
                                        <ext:Store runat="server" ID="VocativeStore" OnReadData="ReloadComboBox">
                                            <Model>
                                                <ext:Model ID="VocativeModel" runat="server" IDProperty="Vocative_ID">
                                                    <Fields>
                                                        <ext:ModelField Name="Vocative_Name" Type="String" />
                                                    </Fields>
                                                </ext:Model>
                                            </Model>
                                        </ext:Store>
                                    </Store>
                                </ext:ComboBox>
                                <ext:Button runat="server" Icon="Add" Margins="0 20 0 0">
                                    <Listeners>
                                        <Click Handler="#{WindowsVocative}.show();"></Click>
                                    </Listeners>
                                    <ToolTips>
                                        <ext:ToolTip runat="server" Html="Thêm mới danh xưng" />
                                    </ToolTips>
                                </ext:Button>
                                <ext:ComboBox ID="cbDepartment"
                                    runat="server"
                                    QueryMode="Local"
                                    SelectOnFocus="true"
                                    ForceSelection="True"
                                    FieldLabel="Phòng ban"
                                    Width="223"
                                    AllowBlank="false"
                                    DisplayField="Department_Name"
                                    ValueField="Department_Id"
                                    EmptyText="Vui lòng chọn phòng ban"
                                    ContextMenuID="cbDepartmentContext" Margins="0 5 0 0">
                                    <Store>
                                        <ext:Store runat="server" ID="DepartmentStore" OnReadData="ReloadComboBox">
                                            <Model>
                                                <ext:Model ID="DepartmentModel" runat="server" IDProperty="Department_Id">
                                                    <Fields>
                                                        <ext:ModelField Name="Department_Name" Type="String" />
                                                    </Fields>
                                                </ext:Model>
                                            </Model>
                                        </ext:Store>
                                    </Store>
                                </ext:ComboBox>
                                <ext:Button runat="server" Icon="Add">
                                    <Listeners>
                                        <Click Handler="#{WindowsDepartment}.show();"></Click>
                                    </Listeners>
                                    <ToolTips>
                                        <ext:ToolTip ID="ToolTip1" runat="server" Html="Thêm mới phòng ban" />
                                    </ToolTips>
                                </ext:Button>
                            </Items>
                        </ext:FieldContainer>
                        <ext:FieldContainer ID="FieldContainer1"
                            runat="server"
                            AnchorHorizontal="100%"
                            Layout="HBoxLayout">
                            <Items>
                                <ext:TextField ID="txtContact_Phone" runat="server" FieldLabel="Điện thoại" Width="250" Margins="0 20 0 0" />
                                <ext:TextField ID="txtContact_MobilePhone" runat="server" FieldLabel="Di động" Width="250" Margins="0 20 0 0" />
                                <ext:TextField ID="txtContact_Email" runat="server" FieldLabel="Email" Vtype="email" Width="250" AllowBlank="false" />
                            </Items>
                        </ext:FieldContainer>
                        <ext:FieldContainer
                            runat="server"
                            AnchorHorizontal="100%"
                            Layout="HBoxLayout">
                            <Items>
                                <ext:TextField ID="txtContact_Address" runat="server" FieldLabel="Địa chỉ" Width="250" AllowBlank="false" Margins="0 20 0 0" />
                                <ext:ComboBox runat="server"
                                    ID="cbProvince"
                                    QueryMode="Local"
                                    SelectOnFocus="true"
                                    ForceSelection="True"
                                    FieldLabel="Tỉnh" Width="223"
                                    DisplayField="Province_Name"
                                    ValueField="Province_Id"
                                    EmptyText="Vui lòng chọn tỉnh"
                                    Margins="0 5 0 0"
                                    ContextMenuID="cbProvinceContext">
                                    <Listeners>
                                        <Select Handler="#{cbDistricts}.clearValue(); #{DistrictsStore}.reload();"></Select>
                                    </Listeners>
                                    <Store>
                                        <ext:Store runat="server" ID="ProvinceStore" AutoLoad="true" OnReadData="ReloadComboBox">
                                            <Model>
                                                <ext:Model ID="ProvinceModel" runat="server" IDProperty="Province_Id">
                                                    <Fields>
                                                        <ext:ModelField Name="Province_Alias" Type="String" />
                                                        <ext:ModelField Name="Province_Name" Type="String" />
                                                    </Fields>
                                                </ext:Model>
                                            </Model>
                                        </ext:Store>
                                    </Store>
                                </ext:ComboBox>
                                <ext:Button runat="server" Icon="Add" Margins="0 20 0 0">
                                    <Listeners>
                                        <Click Handler="#{WindowsProvince}.show();"></Click>
                                    </Listeners>
                                    <ToolTips>
                                        <ext:ToolTip runat="server" Html="Thêm mới tỉnh" />
                                    </ToolTips>
                                </ext:Button>
                                <ext:ComboBox runat="server"
                                    ID="cbDistricts"
                                    QueryMode="Local"
                                    SelectOnFocus="true"
                                    ForceSelection="True"
                                    FieldLabel="Quận huyện" Width="223" AllowBlank="false"
                                    DisplayField="Districts_Name"
                                    ValueField="Districts_Id"
                                    EmptyText="Vui lòng chọn quận huyện"
                                    ContextMenuID="cbDistrictsContext" Margins="0 5 0 0">
                                    <Store>
                                        <ext:Store runat="server" ID="DistrictsStore" AutoLoad="true" OnReadData="ProvinceSelectIndex_Change">
                                            <Model>
                                                <ext:Model ID="DistrictsModel" runat="server" IDProperty="Districts_Id">
                                                    <Fields>
                                                        <ext:ModelField Name="Districts_Name" Type="String" />
                                                    </Fields>
                                                </ext:Model>
                                            </Model>
                                        </ext:Store>
                                    </Store>
                                </ext:ComboBox>
                                <ext:Button runat="server" Icon="Add">
                                    <Listeners>
                                        <Click Handler="#{WindowsDistricts}.show();"></Click>
                                    </Listeners>
                                    <ToolTips>
                                        <ext:ToolTip runat="server" Html="Thêm mới quận huyện" />
                                    </ToolTips>
                                </ext:Button>
                            </Items>
                        </ext:FieldContainer>
                        <ext:TextArea ID="txtContact_Note" runat="server" FieldLabel="Ghi chú" AnchorHorizontal="100%" />
                    </Items>
                </ext:FormPanel>
            </Items>
        </ext:Window>
        <ext:Menu runat="server" ID="cbJobContext">
            <Items>
                <ext:Button ID="Button4" runat="server" Text="Tải lại" Icon="DatabaseRefresh" Flat="True">
                    <Listeners>
                        <Click Handler="#{cbJob}.clearValue(); #{JobStore}.reload(); #{cbJobContext}.hide();"></Click>
                    </Listeners>
                </ext:Button>
            </Items>
        </ext:Menu>
        <ext:Menu runat="server" ID="cbVocativeContext">
            <Items>
                <ext:Button ID="Button2" runat="server" Text="Tải lại" Icon="DatabaseRefresh" Flat="True">
                    <Listeners>
                        <Click Handler="#{cbVocative}.clearValue(); #{VocativeStore}.reload(); #{cbVocativeContext}.hide();"></Click>
                    </Listeners>
                </ext:Button>
            </Items>
        </ext:Menu>
        <ext:Menu runat="server" ID="cbDepartmentContext">
            <Items>
                <ext:Button ID="Button6" runat="server" Text="Tải lại" Icon="DatabaseRefresh" Flat="True">
                    <Listeners>
                        <Click Handler="#{cbDepartment}.clearValue(); #{DepartmentStore}.reload(); #{cbDepartmentContext}.hide();"></Click>
                    </Listeners>
                </ext:Button>
            </Items>
        </ext:Menu>
        <ext:Menu runat="server" ID="cbProvinceContext">
            <Items>
                <ext:Button ID="Button8" runat="server" Text="Tải lại" Icon="DatabaseRefresh" Flat="True">
                    <Listeners>
                        <Click Handler="#{cbProvince}.clearValue(); #{cbProvince1}.clearValue(); #{cbDistricts1}.clearValue(); #{ProvinceStore}.reload(); #{cbDistricts}.setReadOnly(true); #{cbDistricts}.clearValue(); #{cbProvinceContext}.hide();"></Click>
                    </Listeners>
                </ext:Button>
            </Items>
        </ext:Menu>
        <ext:Menu runat="server" ID="cbDistrictsContext">
            <Items>
                <ext:Button ID="Button10" runat="server" Text="Tải lại" Icon="DatabaseRefresh" Flat="True">
                    <Listeners>
                        <Click Handler="#{cbDistricts}.clearValue(); #{cbDistricts1}.clearValue(); #{DistrictsStore}.reload(); #{cbDistrictsContext}.hide();"></Click>
                    </Listeners>
                </ext:Button>
            </Items>
        </ext:Menu>
    </Content>
</ext:Panel>